//
//  AppDelegate.m
//  UI2_UITextField
//
//  Created by Marry W. on 16/1/21.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    // xcode7
    self.window.rootViewController = [[[UIViewController alloc] init] autorelease];
    
    // UITextField 输入框
    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    textField.backgroundColor = [UIColor whiteColor];
    [self.window addSubview:textField];
    [textField release];
    /***** 文本控制 *****/
    // 占位字符串 placeholder
    textField.placeholder = @"红红火火恍恍惚惚";
    /***** 输入控制 *****/
    // 是否可用 enabled
    textField.enabled = YES;
    // 安全文本输入 secureTextEntry
    textField.secureTextEntry = YES;
    // 键盘样式 keyboardType
    //设置键盘样式，比如银行取款密码只需要数字，有的输入邮箱需要@等等
    //UIKeyboardTypeAlphabet和UIKeyboardTypeDefault类似，就是我们平时看到那样，都是字母，然后有个按键可以切换符号
    //UIKeyboardTypeASCIICapable好像和上面差不多
    //UIKeyboardTypeDecimalPad,UIKeyboardTypeNumberPad都是数字，但前者多了一个“小数点”按键
    //UIKeyboardTypeEmailAddress-除了字母还有小数点和@出现
    //UIKeyboardTypeNamePhonePad-貌似正常
    //UIKeyboardTypePhonePad-电话键盘，不仅有数字还有*和#的那种
    //UIKeyboardTypeNumbersAndPunctuation-只有数字和标点符号
    //UIKeyboardTypeTwitter-除了字母还有@和#，这是微博的符号
    //UIKeyboardTypeURL-除字母，还有.com按钮，方便输入
    //UIKeyboardTypeWebSearch-主要区别在于return键变成了GO键
    textField.keyboardType = UIKeyboardTypeDefault;
    // return(回车按键)样式
    textField.returnKeyType = UIReturnKeyGoogle;
    // 开始输入时清空
    textField.text = @"输入的内容";
    textField.clearsOnBeginEditing = YES;
    // 自定义键盘
    UIView *textView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    textView.backgroundColor = [UIColor greenColor];
    // 给输入框指定输入视图为新建的view
//    textField.inputView = textView;
    // 自定义输入辅助视图
    textField.inputAccessoryView = textView;
    /***** 外观控制 *****/
    // 输入框样式
    textField.borderStyle = UITextBorderStyleNone;
    // 边框宽度
    textField.layer.borderWidth = 1;
    // 边框颜色
    textField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    // 切圆角(圆形: 正方形边长的一半)
    textField.layer.cornerRadius = textField.frame.size.width / 2;
    // 清除按钮
    textField.clearButtonMode = UITextFieldViewModeAlways;
    
    
    
    [_window release];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
